RegisterPortlet = Class.extend({
	init: function()	{
		this.name = "RegisterPortlet";
	},
	
	onBegin: function()	{
		this.registerObserver();
	},
	
	onRegisterButtonClick: function()	{
		var email = this.requestForEffectiveResource('Email').val();
		var pwd = this.requestForEffectiveResource('Password').val();
		var fullname = this.requestForEffectiveResource('Fullname').val();
		var alias = this.requestForEffectiveResource('Alias').val();
		
		this.onAjax('user', 'register', {email: email, pwd: pwd, fullname: fullname, alias: alias}, 'POST', {
			'onSuccess': function(ret)	{
				alert("Đăng ký thành công!");
				var subject = SingletonFactory.getInstance(Subject);
				subject.notifyEvent('RequestRoute', new Request('Home'));
			},
			
			'onFailure': function(msg)	{
				alert("Không thể đăng ký: "+msg);
			}
		});
	},
	
	run: function()	{
		this.getPortletPlaceholder().paintCanvas(this.render());
	},
	
	onEnd: function()	{
		this.unregisterObserver();
	}
}).implement(PortletInterface).implement(RenderInterface).implement(AjaxInterface).implement(ObserverInterface);